mui.init();
window.onload = function() {
	mui.plusReady(function() {
		var self = plus.webview.currentWebview();
		var register_phone = self.register_phone;
		$("#register_phones").text(register_phone);

		function invokeSettime(obj) {
			var countdown = 60;
			settime(obj);

			function settime(obj) {
				if(countdown == 0) {
					$(obj).attr("disabled", false);
					$(obj).text("获取验证码");
					countdown = 60;
					return;
				} else {
					$(obj).attr("disabled", true);
					$(obj).text(countdown + "s后重新发送");
					countdown--;
				}
				setTimeout(function() {
					settime(obj)
				}, 1000)
			}
		}
		new invokeSettime("#phone_code");
	})
}
//注册——重新获取验证码
document.getElementById("phone_code").addEventListener("tap", function() {
	var register_phones = $("#register_phones").text(); //手机号码
	function invokeSettime(obj) {
		var countdown = 60;
		settime(obj);

		function settime(obj) {
			if(countdown == 0) {
				$(obj).attr("disabled", false);
				$(obj).text("获取验证码");
				countdown = 60;
				return;
			} else {
				$(obj).attr("disabled", true);
				$(obj).text(countdown + "s后重新发送");
				countdown--;
			}
			setTimeout(function() {
				settime(obj)
			}, 1000)
		}
	}
	new invokeSettime("#phone_code");
	interfRequest.verification_code.data = {
		mobile: register_phones,
		type: 1
	}
	socialRequest(interfRequest.verification_code);
})

//注册——下一步——点击确定
document.getElementById("register_ok").addEventListener("tap", function() {
	var register_phones = $("#register_phones").text(); //手机号码
	var phone_verification_code = $("#phone_verification_code").val(); //获取验证码
	var register_pwd = $("#register_pwd").val(); //密码
	if(!phone_verification_code) {
		mui.alert("请输入验证码！")
		return false;
	}
	if(!register_pwd) {
		mui.alert("请输入密码！")
		return false;
	}
	interfRequest.register.data = {
		account: register_phones, //手机号码
		password: register_pwd, //密码
		sms_code: phone_verification_code //验证码
	}
	socialRequest(interfRequest.register);
})
//注册_重新获取验证码-成功函数回调方法
function verification_codeHandle(data) {
	if(data.error_code == 10000) {
		console.log("注册_重新获取验证码 ==》" + JSON.stringify(data))
	}
}
//注册_确定-成功函数回调方法
function registerHandle(data) {
	if(data.error_code == 10000) {
		mui.alert("注册成功！")
		mui.openWindow({
			url: 'login.html',
			id: 'login',
			createNew: true
		});
	} else {
		mui.alert(data.msg);
	}
}